import time

from selenium.webdriver.support.wait import WebDriverWait

from tools.base_page import BasePage


class AnalyseTools(BasePage):
    def start_analse(self):
        #开始分析
        time.sleep(2)
        # self.open_yaml_element('../data/analysetools.yaml','visual_option_first')
        self.open_yaml_element('../data/analysetools.yaml','visual_option_two')
        self.open_yaml_element('../data/analysetools.yaml','two_option',is_elements=1,ele_num=1)
        two_option_down_menu = self.only_read_yaml('../data/analysetools.yaml','two_option_down_menu')
        time.sleep(1)
        self.selector_execute_script(two_option_down_menu[1])
        time.sleep(2)
        self.open_yaml_element('../data/analysetools.yaml','start_fenxi')
        return self
        #assert '已加入分析任务队列，请耐心等待分析结果' in self.driver.page_source


    def verify_cat_run_res(self):
        '''
        通过查看结果,验证是否运行成功
        :return:
        '''
        self.verify_wait_click(self.only_read_yaml('../data/analysetools.yaml','cat_run_res'))
        self.open_yaml_element('../data/analysetools.yaml','cat_run_res')
        # self.driver.refresh()
        time.sleep(2)
        task_list_status = self.only_read_yaml('../data/analysetools.yaml','task_list_status')
        self.verify_wait_click(task_list_status)
        return  self.find(task_list_status).text



    def cat_run_res(self):
        self.open_yaml_element('../data/analysetools.yaml','cat_run_res')

